#ifndef DYNAMICMAP_H
#define DYNAMICMAP_H

#include <QObject>
#include <QWidget>
#include "common.h"

class DPSockLink;
class ProtocolParse;
class EditWidget;
class ShowWidget;
class ViewObject;

struct  DynamicRunParam
{
    DynamicRunParam();
    //socket
    uint32_t    ip;
    uint16_t    port;               /// 端口
    uint32_t    tcp_ip;
    uint16_t    tcp_port;           ///TCP端口号
    char       inter_addr[64];     /// unix domain
//    char       xml_path[128];
//    char       img_path[128];
    QString     res_path;

};

class DynamicMap : public QObject
{
    Q_OBJECT
public:
    static DynamicMap* get_map();
    void init(QString);
    void kill_old_mvc_python_proc();

    static int  link_buf_send(void *context, void *link_context, void *buf, int len, uint32_t ip, uint16_t port, uint64_t time);
    static void link_svr_data_cb(void *context, void *buf, int buf_len, uint32_t rmt_ip, uint16_t rmt_port, uint64_t cur_time);
    static int  tcp_link_svr_data_cb(void *context, void *buf, int buf_len, uint32_t rmt_ip, uint16_t rmt_port, uint64_t cur_time);
    static void link_inter_msg_cb(void *context, void *buf, int buf_len, char *rmt_addr, uint64_t cur_time);
    static void link_trigger_cb(void *context, uint64_t cur_time);
    static void notify_to_window(void *context, QString file);

//    QString get_xml_path(){return QString(QLatin1Literal(xml_path));}
//    QString get_img_path(){return QString(QLatin1Literal(img_path));}

    QString  get_res_path(){return m_res_path;}

    ProtocolData *ptr_protocol_data;


public slots:

signals:
    void signal_update_file(QString, void*);

private:
    static DynamicMap *map_obj;
    DPSockLink     *linker;
    ProtocolParse  *parse;
    uint32_t        local_ip;
    uint16_t        local_port;
//    char            xml_path[PTAH_LEN];
//    char            img_path[PTAH_LEN];

    QString m_res_path;


private:
    explicit DynamicMap();
    int  create_obj(DynamicRunParam &svr_param);
    void init_param(DynamicRunParam &param);
    void set_protocol(int ptl);
    void set_event_cb();
    int data_prepare();

};


//#ifdef __cplusplus
//}
//#endif
#endif // DYNAMICMAP_H
